package com.actionsoft.ActionEvent;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.sdk.local.SDK;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;

public class AddOrg extends ExecuteListener implements ActionListener {


    @Override
    public void execute(ProcessExecutionContext pec) throws Exception {

        String companyid = "067ef41d-ef45-4c77-93e5-98a2de2cca29";

        BO bo = SDK.getBOAPI().getByProcess("BO_EU_ORG_SAVE",pec.getProcessInstance().getId());
        Map<String,Object> map = bo.asMap();
        System.out.println(map);
        //新建部门
        String departmentid = SDK.getORGAPI().createDepartment(companyid,(String)bo.get("ORG_NAME"),"",(String)bo.get("REGION_NAME"),
                "","","");
        //设置管理员,从填写的bo数据中获得
        SDK.getORGAPI().assertDepartmentManager(departmentid,(String)bo.get("USER_ID"));
        //更新缺失的数据
        bo.set("ORG_ID", departmentid);
        SDK.getBOAPI().update("BO_EU_ORG_SAVE",bo);
    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }
}
